package com.faung.producer;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Created by Fuang on 2018-1-6.
 */
@Component
public class Sender {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send(){
        String context = "hello " + new Date();
        System.out.println("---------------------------------------" + context);
        this.amqpTemplate.convertAndSend("hello", context);
    }

    public void sendTopic(){
        String context = "TOPIC.QUEUE";
        System.out.println("--------------------sendTopic=" + context);
        amqpTemplate.convertAndSend("topicExchange", "topic.queue", context);
    }

    public void sendFanout(){
        String context = "fanoutMessage";
        System.out.println("--------------------sendFanout=" + context);
        amqpTemplate.convertAndSend("fanoutExchange", "fanoutMessage", context);
    }
}
